#ifndef SOCKET_CPP
#define SOCKET_CPP

#include <string>
#include <cstdio>
#include <winsock2.h>
#include <sys/types.h>
#include <ws2tcpip.h>

class Socket
{
	public:
		Socket();
		Socket(SOCKET s);
		Socket(const Socket& s);
		~Socket();
		void Create(std::string protocol);
		void Bind(int port);
		void Listen();

		Socket Accept();
		void Connect(std::string ip, int port);

		//TCP overlapped Functions
		int Recv(std::string& buffer, unsigned int length, OVERLAPPED* overlapped);
		int Recv(char* buffer, unsigned int length, OVERLAPPED* overlapped);
		void Send(std::string buffer, unsigned int length);
		void Send(char* buffer, unsigned int length);

		//UDP Functions
		int RecvFrom(char* buffer, unsigned int length);
		void SendTo(char* buffer, unsigned int length);
		void setMulticastServer(std::string ip, int port);
		void setMulticastClient(std::string ip);

		SOCKET getSocket();

		Socket& operator=(const Socket& s);
		bool operator==(const Socket& s);

	private:
		SOCKET sock;
		
		//address information for the socket
		struct sockaddr_in sin;

		//Multicast join request structure
		struct ip_mreq mc_req;
};

#endif